package com.epam.my.Kulibaba;

import java.util.Collections;
import org.testng.Assert;
import org.testng.annotations.Test;

import com.epam.my.Pages.MailPage;

public class TestWrightAndSendMail extends TestBase {

	@Test
	public void testSendMail() throws Exception {
		MailPage mailPage = goToMainPage().loginWithValidCredentials(
				"nadin_qwerty", "@rambler.ru", "qwerty");
		SorterListOf<Email> oldEmailsList = mailPage.getEmails();		
		Email email = new Email().withSenderName("nadin nadin")
				.withSenderAdress("nadin_qwerty@rambler.ru")
				.withSubjectEmail("check");
		mailPage.createNewEmail().sendNewEmail(email).checkInboxLetter();		
		oldEmailsList.add(email);
		SorterListOf<Email> newEmailsList = mailPage.getEmails();	
		mailPage.logOut();		
		Collections.sort(newEmailsList);
		Collections.sort(oldEmailsList); 
		Assert.assertEquals(newEmailsList, oldEmailsList );			
	}
}
